package com.shrct.businessprocess.purchase.impl;

import com.shrct.businessprocess.product.RCProductEntry;
import com.shrct.businessprocess.product.impl.RCProductEntryImpl;
import com.shrct.businessprocess.purchase.RCProductDeliver;
import com.shrct.businessprocess.purchase.RCProductDeliverItem;
import com.shrct.businessprocess.purchase.impl.RCProductDeliverImpl;
import com.shrct.businessprocess.purchase.proxy.RCProductDeliverItemProxy;
import edu.fudan.mylang.pf.BaseModelObject;
import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.DiscriminatorOptions;

@Entity
@DiscriminatorValue("RCPRODUCTDELIVERITEM_TYPE")
@DiscriminatorOptions(force = true)
@DiscriminatorColumn(length = 64)
@Table(name = "rcproductdeliveritem")
public abstract class RCProductDeliverItemImpl extends BaseModelObject implements RCProductDeliverItem {
  public RCProductDeliverItemImpl() {
    super();
  }
  
  public RCProductDeliverItemImpl(final RCProductDeliver deliver) {
    super();
    this.deliver = deliver;
  }
  
  @JoinColumn(name = "deliver_id")
  @ManyToOne(targetEntity = RCProductDeliverImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductDeliver deliver;
  
  public RCProductDeliver getDeliver() {
    return this.deliver;
  }
  
  public RCProductDeliverItem setDeliver(final RCProductDeliver deliver) {
    this.deliver = deliver;
    return this;			
    
  }
  
  @JoinColumn(name = "product_id")
  @ManyToOne(targetEntity = RCProductEntryImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCProductEntry product;
  
  public RCProductEntry getProduct() {
    return this.product;
  }
  
  public RCProductDeliverItem setProduct(final RCProductEntry product) {
    this.product = product;
    return this;			
    
  }
  
  private Date date;
  
  public Date getDate() {
    return this.date;
  }
  
  public RCProductDeliverItem setDate(final Date date) {
    this.date = date;
    return this;			
    
  }
  
  public RCProductDeliverItemProxy toProxy() {
    com.shrct.businessprocess.purchase.proxy.RCProductDeliverItemProxy proxy = new com.shrct.businessprocess.purchase.proxy.RCProductDeliverItemProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
